<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use yii\bootstrap\ActiveForm;
use yii\widgets\Breadcrumbs;
use app\modules\clinical\models\Patient;
use app\models\Helpers;

/* @var $this yii\web\View */
/* @var $model app\models\Patient */

$this->title = $model->pt_name;
$this->params['breadcrumbs'][] = ['label' => '临床信息', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => '基本信息'];

$pic = Helpers::checkExist("pt_family");

?>

<?= Breadcrumbs::widget([
  'homeLink' => ['label' => '医疗管理系统', 'url' => '#'],
  'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
]) ?>

<div class="patient-view">

    <p>
        <?= (!isset($from)) ? Html::a('修改', ['/clinical/patient/update', 'id' => $model->pk_id], ['class' => 'btn btn-primary']) : '' ?>
        <?= (isset($from)) ? Html::a('返回', '/clinical/relative', ['class' => 'btn btn-success']) : '' ?>

        <?= (!isset($from)) ? Html::a('删除', ['delete', 'id' => $model->pk_id], [
            'class' => 'btn btn-danger btn-right',
            'data' => [
                'confirm' => '确定删除?',
                'method' => 'post',
            ],
        ]) : '' ?>
    </p>
    </p>

    <table class="table table-striped table-bordered detail-view">
        <tr>
            <th>姓名</th>
            <td><?= $model->pt_name ?></td>
            <th>出生日期</th>
            <td><?= $model->pt_birth ?></td>
            <th>病案号</th>
            <td><?= $model->pt_id ?></td>
        </tr>
        <tr>
            <th>性别</th>
            <td><?= Patient::getParams('sex', $model->pt_sex) ?></td>
            <th>民族</th>
            <td><?= Patient::getParams('nation', $model->pt_nation) ?></td>
            <th>婚姻状况</th>
            <td><?= Patient::getParams('marry', $model->pt_marry) ?></td>
        </tr>
        <tr>
            <th>详细通讯地址</th>
            <td colspan="3"><?= $model->pt_addr ?></td>
            <th>惯用手</th>
            <td><?= Patient::getParams('customary', $model->pt_customary) ?></td>
        </tr>
        <tr>
            <th>文化程度</th>
            <td><?= Patient::getParams('edu', $model->pt_edu) ?></td>
            <th>职业</th>
            <td><?= $model->pt_vocation ?></td>
            <th>医保</th>
            <td><?= Patient::getParams('insurance', $model->pt_insu) ?></td>
        </tr>
        <tr>
            <th>与患者关系1</th>
            <td><?= Patient::getParams('relation', $model->rel_relation1) ?></td>
            <th>联系电话1</th>
            <td><?= $model->rel_phone1 ?></td>
            <th>电子邮件1</th>
            <td><?= $model->rel_email1 ?></td>
        </tr>
        <tr>
            <th>与患者关系2</th>
            <td><?= Patient::getParams('relation', $model->rel_relation2) ?></td>
            <th>联系电话2</th>
            <td><?= $model->rel_phone2 ?></td>
            <th>电子邮件2</th>
            <td><?= $model->rel_email2 ?></td>
        </tr>
        <tr>
            <th>发病年龄</th>
            <td><?= ($model->pt_age == 0) ? '' : $model->pt_age ?></td>
            <th>有无家族史</th>
            <td><?= Patient::getParams('youwu', $model->pt_fml) ?></td>
            <th>父母是否近亲</th>
            <td><?= Patient::getParams('yesno', $model->pt_jinqin) ?></td>
        </tr>
        <tr>
            <th>既往史</th>
            <td colspan="5"><?= Patient::getHistory($model->pt_history) ?></td>
        </tr>
        <tr>
            <th>标签</th>
            <td><?= Patient::getLabel($model->pt_label) ?></td>
            <th>诊断</th>
            <td><?= is_numeric($model->pt_disease) ? Patient::getParams('disease', $model->pt_disease) : $model->pt_disease ?></td>
            <td rowspan="6" colspan="2">
              <b>家系图：</b><br />
              <a href="<?= $pic['href'] ?>" target="_blank">
                <img <?= $pic['name'] ?> width="200px">
              </a>
            </td>
        </tr>
        <tr>
            <th>备注</th>
            <td colspan="3"><?= $model->pt_note ?></td>
        </tr>
        <tr>
            <th>是否配合</th>
            <td><?= Patient::getParams('yesno', $model->isCooperate) ?></td>
            <th>是否死亡</th>
            <td><?= ($model->pt_dead == '1001-01-01') ? '否' : '是 ('.$model->pt_dead.')' ?></td>
        </tr>
        <tr>
            <th>就诊医院</th>
            <td><?= $model->pt_hsp ?></td>
            <th>介绍人</th>
            <td><?= $model->pt_intro ?></td>
        </tr>
        <tr>
            <th>创建人</th>
            <td><?= $model->crt_name ?></td>
            <th>创建日期</th>
            <td><?= $model->crt_date ?></td>
        </tr>
        <tr>
            <th>修改人</th>
            <td><?= $model->update_name ?></td>
            <th>修改日期</th>
            <td><?= $model->update_at ?></td>
        </tr>
    </table>

</div>
